var app = angular.module('myApp', []);
app.controller('customersCtrl', function ($scope, $http) {
    $http.get('http://127.0.0.1:8080/getList')
        .success(function (Data) {
            $scope.result = Data.data;
            // console.info(Data);
        });

    //创建当前正在编辑的对象
    $scope.currentStu = {
        sh_id:'',
        sh_city:'',
        sh_shool:'',
    };
    $scope.deleteStu = function (id) {
        $http.delete('http://127.0.0.1:8080/delete/'+id)
            .success(function (Data) {
                console.info(Data);
            });
        console.log("删除事件!"+id)
    };
    $scope.addStu = function (params) {
        console.log(params.sh_id)
        if (params.sh_id !== '' && params.sh_id > 0){
            $http.put('http://127.0.0.1:8080/update?sh_id='+params.sh_id+'&sh_city='+params.sh_city+'&sh_shool='+params.sh_shool)
                .success(function (Data) {
                    console.info(Data);
                });
            console.log("修改")
        }else {
            $http.post('http://127.0.0.1:8080/add?sh_city='+params.sh_city+'&sh_shool='+params.sh_shool)
                .success(function (Data) {
                    console.info(Data);
                });
            console.log("添加事件!");
        }

    };
    $scope.isSelected = function (currentrow) {
        console.info(currentrow);
        return currentrow;
    };
    $scope.editStu = function (item) {
        console.log("编辑事件!"+item.sh_id);
        $scope.currentStu = item;
    };
});